/*
* Conditions Of Use
*
* This software was developed by employees of the Sigmatrix(Beijing) Corporation.
* This software is provided by sigmatrix as a service and is expressly
* provided "AS IS."  Sigmatrix MAKES NO WARRANTY OF ANY KIND, EXPRESS, IMPLIED
* OR STATUTORY, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTY OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT
* AND DATA ACCURACY.  Sigmatrix does not warrant or make any representations
* regarding the use of the software or the results thereof, including but
* not limited to the correctness, accuracy, reliability or usefulness of
* the software.
*
* Permission to use this software is contingent upon your acceptance
* of the terms of this agreement.
*
*/
package com.fileLoader.service.impl;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Random;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;import org.springframework.beans.factory.FactoryBeanNotInitializedException;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

import com.fileLoader.pojo.mongo.FilePosition;
import com.fileLoader.pojo.mongo.FilePositionSetting;
import com.fileLoader.service.fileLoadService;

/**
 *@ClassName: fileLoadServiceImpl
 *@Description: TODO()
 *@author libin
 *@date 2017年11月8日 下午2:10:27
 */
@Service
public class fileLoadServiceImpl implements fileLoadService {
	//push   12312312
	@Resource
	MongoTemplate mongoTemplate;
	
	Logger logger = LoggerFactory.getLogger(com.fileLoader.pojo.fileDict.class);
	
	Random random = new Random();
	
//	@Scheduled(cron="0/5 * *  * * ? ") 
	public void doFile(){
		FilePositionSetting filePositionSetting = new FilePositionSetting();
		filePositionSetting.setBaseFileName("scan.log");
		filePositionSetting.setStatus(1);
		filePositionSetting.setCollectionName("scan");
		filePositionSetting.setSettingTpye(1);
		
		List<FilePosition> filePositions = new ArrayList<FilePosition>();
		FilePosition filePosition = new FilePosition();
		filePosition.setDirectory("/scan");
		filePosition.setPath("e:/data/logs");
		filePosition.setStatus(1);
		filePositions.add(filePosition);
		
		List<FilePosition> filePositions2 = new ArrayList<FilePosition>();
		FilePosition filePosition2 = new FilePosition();
		filePosition2.setDirectory("/scanHistory");
		filePosition2.setPath("e:/data/logsHistory");
		filePosition2.setStatus(1);
		filePositions2.add(filePosition2);
		
		
		filePositionSetting.setWriteFilePositions(filePositions);
		filePositionSetting.setMoveFilePositions(filePositions2);
		mongoTemplate.save(filePositionSetting);
	}
}
